#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
    //printf("begin......\n");
    //printf("begin......\n");
    //printf("begin......\n");
    //printf("begin......\n");
    //execl("/bin/ls", "ls", "-a", "-l", NULL);
    //printf("end......\n");
    //printf("end......\n");
    //printf("end......\n");
    //printf("end......\n");
    //char* const argv[] = 
    //{
    //    "ls",
    //    "-a",
    //    "-l",
    //    "-n",
    //    NULL
    //};
    //execv("/bin/ls", argv);
    
    //execlp("ls", "ls", "-a", "-l", NULL);
    
    //execvp("ls", argv);
    extern char** environ;
    pid_t id = fork();
    if (id == 0)
    {
        printf("我是子进程，pid:%d\n", getpid());
        //char* const myenv[] = 
        //{
        //    "MYENV=YouCanSeeMe",
        //    NULL
        //};
        //putenv("MYENV=YouCanSeeMe");
        execle("./exec/otherproc", "otherproc", NULL, myenv);
        exit(0);
    }
    int status = 0;
    printf("我是父进程，pid:%d\n", getpid());
    waitpid(id, &status, 0);
    printf("child exit code:%d\n", WEXITSTATUS(status));
    return 0;
}
